package org.example

import java.io.File
import scala.collection.mutable.Map
import scala.io.Source

case object wordcount1{
  def main2(args: Array[String]): Unit = {
    val dirfile = new File("word\\lx")
    val files = dirfile.listFiles
    val results = Map.empty[String, Int]
    for (file <- files) {
      val data = Source.fromFile(file)
      val strs = data.getLines.flatMap { s => s.split(" ") }
      strs foreach { word =>
        if (results.contains(word))
          results (word) += 1 else results(word) = 1

      }
    }
    var list=results filter {kv=>kv._1.length >2}
    list foreach { case (k, v) => println(s"$k:$v") }

  }

  def main(args: Array[String]): Unit = {

  }
}